/**
 * Created by liujinghao on 12/12 0012.
 *
 */
var data1=[659,532,266,304,252,205,137]
var data2=[2289,636,652,522,466,822,1658]
var data3=[571,843,383,932,1019,2084,1390]

var data4=[7660,28471,15231]
var data5= [238631,738688,928315]
    // 游客日数据同期对比
    var option_day_forecast = {
        color: ['#2ceb43','#fbec47','#fe212a','#4ab6fe','#9933CC',"#BF3EFF","#4876FF"],
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            left: '2%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        legend: {
            top: 2,
            icon: "rect",
            right: '4%',
            itemWidth: 30,
            itemHeight: 10,
            itemGap: 13,
            borderRadius: 5,
            data: ['2017年', '2018年','2019年'],
            textStyle: {
                fontSize: 12,
                color: '#F1F1F3'
            }
        },
        textStyle: {
            color: "#d2d2d2"
        },
        calculable: true,
        xAxis: [
            {
                type: 'category',
                boundaryGap: false,
                axisLine: {
                    lineStyle: {
                        color: '#475f79'
                    }
                },
                data: ['11-04','11-05','11-06','11-87','11-09','11-10']
            }
        ],
        yAxis: [
            {
                type: 'value',
                axisLabel: {
                    formatter: '{value}'
                },
                axisLine: {
                    lineStyle: {
                        color: '#475f79'
                    }
                },
                splitLine: {
                    show: true,
                    lineStyle: {
                        // 使用深浅的间隔色
                        color: ['#2f2f2f']
                    }
                },
            }
        ],
        series: [
            {
                name: '2017年',
                type: 'line',
                smooth: true,
                showSymbol: true,
                symbol: 'circle',
                symbolSize:4,
                data: data1,
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: "rgba(101, 234, 114, 0.3)"
                        }, {
                            offset: 1,
                            color: "rgba(255, 255, 255, 0)"
                        }], false),
                    }
                },
            },
            {
                name: '2018年',
                type: 'line',
                smooth: true,
                showSymbol: true,
                symbol: 'circle',
                symbolSize: 4,
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: "rgba(251, 240, 129, 0.3)"
                        }, {
                            offset: 1,
                            color: "rgba(255, 255, 255, 0)"
                        }], false),
                    }
                },
                data:data2 ,
            },
            {
                name: '2019年',
                type: 'line',
                smooth: true,
                showSymbol: true,
                symbol: 'circle',
                symbolSize: 4,
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: "rgba(245, 68, 75, 0.3)"
                        }, {
                            offset: 1,
                            color: "rgba(255, 255, 255, 0)"
                        }], false),
                    }
                },
                data: data3,
            },
        ]
    };
var dayDiv = echarts.init(document.getElementById('dayDiv'));
// 渲染页面初始数据
dayDiv.setOption(option_day_forecast);
// function setDay(data) {
//     option_day_forecast.legend.data=data.legend;
//     option_day_forecast.xAxis[0].data=data.xAxis;
//     var confArr = [];
//     data.data.forEach(function (val,key) {
//         var obj = $.extend(true, {}, option_day_forecast.series[0]);
//         obj.name=String(val.name);
//         obj.data=val.data;
//         confArr.push(obj)
//     })
//     option_day_forecast.series=confArr;
//     var dayDiv = echarts.init(document.getElementById('dayDiv'));
//     dayDiv.setOption(option_day_forecast);
// }
// function daySearch(t1, t2,type) {
//     var opt = {
//         type: 'get',
//         url: '/bigdata/manage/tourist-compare/day-compare',
//         data: {},
//         callback: function (res) {
//             if (res.code == 1) {
//                 dyw.box.alert(res.msg);
//                 return false
//             }
//             setDay(res.result);
//             $("#date1").val(res.result.start_time);
//             $("#date2").val(res.result.end_time);
//         }
//     }
//     if (t1) {
//         opt.data = {
//             start_time: t1,
//             end_time: t2
//         }
//     }
//     if(type)  opt.data.type=type;
//     loadData(opt)
// }
// daySearch();
$("#search1").on('click', function () {
    var t1 = $("#date1").val();
    var t2 = $("#date2").val();
    var type=$("#type1").val()
    if (!t1 || !t2) {
        dyw.box.alert('请选择查询时间');
        return false
    }
    // daySearch(t1, t2,type);
})
// $("#type1").change(function () {
//     $("#search1").click();
// })


// 游客月数据
var option_month = {
    color: ['#4bb6fc', '#fbec47', '#fe212a', '#4ab6fe'],
    grid: {
        top:15,
        left: '2%',
        right: '5%',
        bottom: '3%',
        containLabel: true
    },
    tooltip: {
        trigger: 'axis'
    },
    textStyle: {
        color: "#d2d2d2"
    },
    calculable: true,
    xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            axisLine: {
                lineStyle: {
                    color: '#475f79'
                }
            },
            data: ['2017-11', '2018-11', '2019-11']
        }
    ],
    yAxis: [
        {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            },
            axisLine: {
                lineStyle: {
                    color: '#475f79'
                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    // 使用深浅的间隔色
                    color: ['#2f2f2f']
                }
            },
        }
    ],
    series: [
        {
            name: '人数',
            type: 'line',
            symbolSize: 4,
            smooth: true,
            showSymbol: true,
            symbol: 'circle',
            data: data4,
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: "rgba(75, 182, 252, 0.5)"
                    }, {
                        offset: 1,
                        color: "rgba(255, 255, 255, 0.2)"
                    }], false),
                }
            },
        } 
    ]
};
// 渲染静态页面
var monthDiv = echarts.init(document.getElementById('monthDiv'));
monthDiv.setOption(option_month);


// function setMonth(data) {
//     console.log(data.xAxis)
//     console.log(data.series)
//     option_month.xAxis[0].data=data.xAxis;
//     option_month.series[0].data=data.data;
//     var monthDiv = echarts.init(document.getElementById('monthDiv'));
//     monthDiv.setOption(option_month);
// }

// function monthSearch(month, type) {
//     var opt = {
//         type: 'get',
//         url: '/bigdata/manage/tourist-compare/month-compare',
//         data: {},
//         callback: function (res) {
//             if (res.code == 1) {
//                 dyw.box.alert(res.msg);
//                 return false
//             }
//             setMonth(res.result);
//             $("#date3").val(res.result.month);
//         }
//     }
//     if (month) {
//         opt.data = {
//             month: month,
//         }
//     }
//     if (type) opt.data.type = type;
//     loadData(opt)
// }
// monthSearch();

// $("#search2").on('click', function () {
//     var t1 = $("#date3").val();
//     var type = $("#type2").val()
//     if (!t1) {
//         dyw.box.alert('请选择查询时间');
//         return false
//     }
//     monthSearch(t1, type);
// })
// $("#type2").change(function () {
//     $("#search2").click()
// })


// 年数据
var option_year = {
    color: ['#099fac', '#fbec47', '#fe212a', '#4ab6fe'],
    grid: {
        top:'5%',
        left: '2%',
        right: '3%',
        bottom: '3%',
        containLabel: true
    },
    tooltip: {
        trigger: 'axis'
    },
    textStyle: {
        color: "#d2d2d2"
    },
    calculable: true,
    xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            axisLine: {
                lineStyle: {
                    color: '#475f79'
                }
            },
            data: ['2017', '2018','2019']
        }
    ],
    yAxis: [
        {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            },
            axisLine: {
                lineStyle: {
                    color: '#475f79'
                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    // 使用深浅的间隔色
                    color: ['#2f2f2f']
                }
            },
        }
    ],
    series: [
        {
            name: '人数',
            type: 'line',
            symbolSize: 4,
            smooth: true,
            showSymbol: true,
            symbol: 'circle',
            data:data5,
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: "rgba(9, 158, 171, 0.5)"
                    }, {
                        offset: 1,
                        color: "rgba(255, 255, 255, 0.1)"
                    }], false),
                }
            },
        },
    ]
};

var yearDiv = echarts.init(document.getElementById('yearDiv'));
yearDiv.setOption(option_year);

// function setYear(data) {
//     option_year.xAxis[0].data = data.xAxis;
//     option_year.series[0].name = data.data.name;
//     option_year.series[0].data = data.data.value;
//     var yearDiv = echarts.init(document.getElementById('yearDiv'));
//     yearDiv.setOption(option_year);
// }
// function yearSearch( type) {
//     var opt = {
//         type: 'get',
//         url: '/bigdata/manage/tourist-compare/year-compare',
//         data: {},
//         callback: function (res) {
//             if (res.code == 1) {
//                 dyw.box.alert(res.msg);
//                 return false
//             }
//             setYear(res.result)
//         }
//     }
//     if (type) opt.data.type = type;
//     loadData(opt)
// }
// yearSearch();

// $("#type3").change(function () {
//     var type = $("#type3").val()
//     yearSearch(type);
// })


$('.day-cons').find('#type1').change(function(){
data1=[659,532,666,1204,252,205,137]
    data2=[2289,1036,952,522,466,822,1658]
    data3=[571,243,1500,932,1019,2084,1390]
dayDiv = echarts.init(document.getElementById('dayDiv'));
    dayDiv.setOption(option_day_forecast)

})

$('.month').find('#type2').change(function(){
    data4=[7260,28471,10231]
    var monthDiv = echarts.init(document.getElementById('monthDiv'));
    monthDiv.setOption(option_month);
    
    })
    $('.year').find('#type3').change(function(){
        data5= [230631,768688,968315]
        var yearDiv = echarts.init(document.getElementById('yearDiv'));
        yearDiv.setOption(option_year);
        
        })







